package converter;

import java.util.Map;

import model.ServiceCall;

import org.apache.struts2.util.StrutsTypeConverter;

import persistency.ServiceCallRepository;

public class ServiceCallConverter  extends StrutsTypeConverter{

	
	    
	    public Object convertFromString(Map context, String[] values, Class toClass) {
			try{
	    	ServiceCallRepository scr = new ServiceCallRepository();
			return scr.getById(new Integer(values[0]));
			}catch(Exception e){
				e.printStackTrace();
			}
			return null;
	       
	    }

	    public String convertToString(Map context, Object o) {
	    	ServiceCall sc =(ServiceCall)o;
			return ""+sc.getId();
	      
	    }
	
	
	
}
